package com.wang.web;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: wang
 * @date: 2021/7/28 10:43
 * @description:
 */
@WebServlet("/set")
public class SessionServletTestSet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req,resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String user = "this one is a very strange and mean guy";
        req.getSession().setAttribute("user",user);
        resp.getWriter().write("ye had saved it");
    }
}
